package com.crossriver.crgis.cofo.util;

import java.rmi.RemoteException;

import org.apache.axis2.AxisFault;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.interswitchng.services.WebPayServiceStub;
import com.interswitchng.services.WebPayServiceStub.TransactionQueryResponse;

public class PaymentServiceUtil {
	
	private static Log log = LogFactory.getLog(PaymentServiceUtil.class);

	
	public static TransactionQueryResponse makeServiceCall(String hash, String productId, String txnRef){
		if(log.isInfoEnabled()){
			log.info("in makeServiceCall(");		
		}
		//OperationClient opClient = sc.createClient(ServiceClient.ANON_OUT_IN_OP);
		
		TransactionQueryResponse transDataResponse = null;
		
		WebPayServiceStub stub;
		try {
			stub = new WebPayServiceStub();
			
			WebPayServiceStub.TransactionQueryRequest request = new WebPayServiceStub.TransactionQueryRequest();
			request.setHash(hash);
			request.setProductId(productId);
			request.setTransactionReference(txnRef);
			
			WebPayServiceStub.GetTransactionData transData = new WebPayServiceStub.GetTransactionData();
			transData.setTransactionQueryRequest(request);
			
			WebPayServiceStub.GetTransactionDataResponse response = stub.getTransactionData(transData);
			
			transDataResponse = response.getGetTransactionDataResult();
			
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	
		return transDataResponse;
	}

}
